package com.ruoyi.ai.api;

import com.ruoyi.ai.api.bo.WxChatMessageBo;
import com.ruoyi.ai.api.bo.WxMaChatQueryBo;
import com.ruoyi.ai.domain.bo.WxChatBo;
import com.ruoyi.ai.domain.vo.WxChatVo;
import com.ruoyi.ai.service.IWxChatService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 微信小程序-聊天接口
 *
 * @author ruoyi
 * @date 2024-04-01
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wx/ma/chat")
public class WxMaChatController extends BaseController {

    private final IWxChatService iWxChatService;

    /**
     * 查询聊天记录列表
     */
    @PostMapping("/list")
    public R<List<WxChatVo>> list(@RequestBody WxMaChatQueryBo queryBo) {
        WxChatBo bo = new WxChatBo();
        bo.setDialogueId(queryBo.getDialogueId());
        Map<String, Object> params = bo.getParams();
        params.put("orderBySort", "asc");
        return R.ok(iWxChatService.queryList(bo));
    }

    /**
     * 聊天
     */
    @PostMapping("/chat")
    public R<Void> chat(@RequestBody WxChatMessageBo chatMessageBo) {
        iWxChatService.chat(chatMessageBo);
        return R.ok();
    }



}
